package com.tkjt.pms.modules.manageWeight.controller;

import com.tkjt.pms.modules.manageWeight.model.TkIndexWeightEntityVO;
import com.tkjt.pms.modules.manageWeight.model.TkIndexWeightModel;
import com.tkjt.pms.modules.manageWeight.service.WeightService;
import lombok.extern.slf4j.Slf4j;
import net.sf.json.JSONObject;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

@Slf4j
@RestController
@RequestMapping("/api/manageWeight")
public class WeightController {
    final
    WeightService weightService;

    public WeightController(WeightService weightService) {
        this.weightService = weightService;
    }

    /**
     * 一线权重列表
     */
    @GetMapping("/yixianWeightList")
    public JSONObject getMyReportrowList(HttpServletRequest request) {
        TkIndexWeightModel model=weightService.getYixianAndBenBuWeightList(request,"1");
        JSONObject result=JSONObject.fromObject(model);
        log.info(result.toString());
        return result;
    }

    @GetMapping("/benbulist")
    public JSONObject benbulist(HttpServletRequest request) {
        TkIndexWeightModel model=weightService.getYixianAndBenBuWeightList(request,"2");
        JSONObject result=JSONObject.fromObject(model);
        log.info(result.toString());
        return result;
    }

    @GetMapping("/saveRows")
    public JSONObject saveRows(HttpServletRequest request,TkIndexWeightEntityVO vo){
        String message=weightService.saveRows(request,vo);
        JSONObject result=new JSONObject();
        result.put("message",message);
        return result;
    }

}
